/*
 * @Author: 江舟 jijiangzhou@recycloud.cn
 * @Date: 2024-03-26 14:58:25
 * @LastEditors: 江舟 jijiangzhou@recycloud.cn
 * @LastEditTime: 2024-08-09 10:18:03
 * @FilePath: \vite-project\src\apis\common\index.ts
 */
import http from 'utils/http';

/**
 * 登录
 * @param data.userName                账户名
 * @param data.passwd                     密码
 * @returns
 */
export const login = (data: API.LoginRequestType) => http<{}, API.LoginResponseType>({
        url: '/api/user/loginUser',
        method: 'post',
        data,
    });

/**
 * 获取登录图片验证码
 * @param data.userName                账户名
 * @param data.smsCode                    验证码
 * @returns
 */
export const sendPicCaptcha = (data: API.LoginRequestType) => http<
        {},
        {
            picKey?: string;
            picBase64?: string;
        }
    >({
        url: '/api/user/sendPicCaptcha',
        method: 'post',
        data,
    });

/**
 * 获取短信验证码
 * @param data.userName                账户名
 * @param data.smsCode                    验证码
 * @returns
 */
export const sendLoginSmsCode = (data: API.LoginRequestType) => http<{}, API.LoginResponseType>({
        url: '/api/user/sendLoginSmsCode',
        method: 'post',
        data,
    });

/**
 * 短信验证码登录
 * @param data.userName                账户名
 * @param data.smsCode                    验证码
 * @returns
 */
export const loginByMoobile = (data: API.LoginRequestType) => http<{}, API.LoginResponseType>({
        url: '/api/user/smsLoginUser',
        method: 'post',
        data,
    });

/**
 * 获取用户信息
 * @param data.userName                账户名
 * @param data.passwd                     密码
 * @returns
 */
export const getLoginUserInfo = () => http<{}, API.LoginUserInfoResponseType>({
        url: '/api/user/queryDetailLoginUser',
        method: 'post',
        data: {},
    });

/**
 * 获取菜单
 * @param data.userName                账户名
 * @param data.passwd                     密码
 * @returns
 */
export const queryUserAuthedMenuTree = () => http<
        {},
        {
            menuTree: any;
        }
    >({
        url: '/api/menu/queryUserAuthedMenuTree',
        method: 'post',
        data: {
            module: 1,
        },
    });

/**
 * 获取文件上传URL
 * @param file
 * @returns
 */
export const getAuthFileUploadUrl = (data: {}) => http<
        {},
        {
            authPutUrl: string;
            attachId: string;
            filePath?: string;
        }
    >({
        url: '/api/carFile/getAuthFileUploadUrl',
        method: 'post',
        data,
    });

/**
 * 确认上传
 * @param file
 * @returns
 */
export const confirmAuthFileUploadUrl = (data: {}) => http<
        {},
        {
            authQueryFileUrl: string;
        }
    >({
        url: '/api/carFile/confirmAuthFileUploadUrl',
        method: 'post',
        data,
    });

/**
 * 查询菜单树列表
 * @param data.appId                应用ID
 * @param data.queryCondition       查询条件（名称）
 * @returns
 */
export const getMenuTree = (data?: any) => http<
        any,
        {
            menuTree?: any;
        }
    >({
        url: '/api/menu/queryMenuTree',
        method: 'post',
        data: {
            ...data,
        },
    });

/**
 * 查询机构树列表
 * @param data.name                组织机构名称
 * @param data.type                组织机构类型
 * @returns
 */
export const getOrgTree = (data: any) => http({
        url: '/api/organization/queryLoginOrgTree',
        method: 'post',
        data,
    });

/**
 * 应用列表查询
 * @param data.pageSize           分页每页的数量
 * @param data.pageNumber         分页当前页
 * @param data.containsMenusTag   包含菜单标识：1-包含菜单、0-不包含菜单
 * @returns
 */
export const getAppList = (data: object) => http({ url: '/api/app/pageApps', method: 'post', data });

/**
 * 查询角色列表
 * @param data.appId               应用ID
 * @param data.organizationId      组织机构id
 * @returns
 */
export const getRoleList = (data: any) => http({
        url: '/api/role/queryRolesByOrgIdOrAppId',
        method: 'post',
        data,
    });

/**
 * 获取应用类型下可用的字典值列表
 * @param data
 * @returns
 */
export const listAllAvaliableValueOfType = (data: any) => http<
        {},
        {
            values: [];
        }
    >({
        url: '/api/dataDict/listAllAvaliableValueOfType',
        method: 'post',
        data,
    });

/**
 * OCR 识别身份证正面
 * @param data
 * @returns
 */
export const ocrIdCardFirstFromOss = (data?: any) => http<
        {},
        {
            factories: [];
        }
    >({
        url: '/api/ocr/idCardFirstFromOss',
        method: 'post',
        data,
        skipError: true,
    });

/**
 * OCR 识别营业执照
 * @param data
 * @returns
 */
export const ocrBusinessLicenseFromOss = (data?: any) => http<
        {},
        {
            factories: [];
        }
    >({
        url: '/api/ocr/businessLicenseFromOss',
        method: 'post',
        data,
        skipError: true,
    });

/**
 * OCR 银行卡
 * @param data
 * @returns
 */
export const ocrBankCardFirstFromOss = (data?: any) => http<
        {},
        {
            factories: [];
        }
    >({
        url: '/api/ocr/bankCardFirstFromOss',
        method: 'post',
        data,
    });

/**
 * OCR  行驶证正面
 * @param data
 * @returns
 */
export const ocrVehicleLicenseFirstFromOss = (data?: any) => http<
        {},
        {
            factories: [];
        }
    >({
        url: '/api/ocr/vehicleLicenseFirstFromOss',
        method: 'post',
        data,
        skipError: true,
    });

/**
 * OCR  过磅单
 * @param data
 * @returns
 */
export const ocrWeighingReceiptFromOss = (data?: any) => http<
        {},
        {
            factories: [];
        }
    >({
        url: '/api/ocr/weighingReceiptFromOss',
        method: 'post',
        data,
        skipError: true,
    });

/**
 * OCR  机动车注册证书
 * @param data
 * @returns
 */
export const ocrVehicleRegistrationFromOss = (data?: any) => http<
        {},
        {
            factories: [];
        }
    >({
        url: '/api/ocr/vehicleRegistrationFromOss',
        method: 'post',
        data,
        skipError: true,
    });

/**
 * OCR 发票
 * @param data
 * @returns
 */
export const ocrInvoiceFromOss = (data?: any) => http<
        {},
        {
            factories: [];
        }
    >({
        url: '/api/ocr/invoiceFromOss',
        method: 'post',
        data,
        skipError: true,
    });

/**
 * OCR 银行回单
 * @param data
 * @returns
 */
export const ocrBankslipFromOss = (data?: any) => http<
        {},
        {
            factories: [];
        }
    >({
        url: '/api/ocr/idCardFirstFromOss',
        method: 'post',
        data,
        skipError: true,
    });
